
package charmander.android.mini;

import java.util.List;

import android.app.Activity;
import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;
import android.gesture.Prediction;

import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.Toast;


import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;



public class AndroidMini extends MapActivity implements OnGesturePerformedListener{
    /** Called when the activity is first created. */
	LinearLayout linearLayout;
	MapView mapView;
	GestureLibrary mlib;
		
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);
        
        GestureOverlayView gestureView = (GestureOverlayView)findViewById(R.id.gestures);
        gestureView.addOnGesturePerformedListener(this);
        mlib = GestureLibraries.fromRawResource(this, R.raw.gestures);        
        if(!mlib.load())
            return;               
    }
    
    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }
    
    @Override
    public void onGesturePerformed(GestureOverlayView view, Gesture gesture)
    {
//    	this.finish();
        List<Prediction> predictions = mlib.recognize(gesture);
        for(Prediction predict : predictions)
        {
            if(predict.score > 1)
            { 
                this.finish();
            }
        }
    }

       
}

